package EA;
import java.util.Hashtable;

/** This class can be used to evaluate TreeGenomes in a somewhat faster way 
    that using the TreeGenomes evaluate. It is useful if you want to plot 
    the value of the expression represented by a treegenome.
*/
public class TreeGenomeFastEval
{
  public TreeGenomeFastEval[] sons;

  public TreeGenomeFastEval()
    {
      super();
      sons = new TreeGenomeFastEval[0];
    }

  public TreeGenomeFastEval(TreeGenomeFastEval[] thesons)
    {
      super();
      sons = thesons;
    }

  /** Evaluate the expression. */
  public Object evaluate()
    {
      return null;
    }

  /** Evaluate the expression where some of the parts of the expression
      can be passed by putting them in the hashtable.
  */
  public Object evaluate(Hashtable htable)
    {
      return null;
    }

  /** Evaluate the sons and return an array containing the results. This 
      can be used when subclassing.
  */
  public Object[] evaluateSons()
    {
      Object[] res = new Object[sons.length];

      for (int i=0;i<sons.length;i++) {
	res[i] = sons[i].evaluate();
      }
      return res;
    }


  /** Evaluate the sons and return an array containing the results.
      You can pass the Hashtable so the sons are evaluated in that context.
      This can be used when subclassing.
  */
  public Object[] evaluateSons(Hashtable htable)
    {
      Object[] res = new Object[sons.length];

      for (int i=0;i<sons.length;i++) {
	res[i] = sons[i].evaluate(htable);
      }
      return res;
    }

}

